package com.zj.processors;


import com.zj.bean.KeyValue;
import com.zj.bean.RunParams;
import com.zj.bean.TableInfo;
import com.zj.data.DataCenter;
import com.zj.job.CommonJob;
import org.apache.commons.lang.StringUtils;

public abstract class BaseCommonProcessor extends BaseProcessor implements CommonProcessor{

    protected CommonJob commonJob;
    protected TableInfo tableInfo;

    public void init(TableInfo tableInfo,CommonJob commonJob) {
        this.tableInfo=tableInfo;
        this.commonJob = commonJob;
    }


    @Override
    public String getParam(String key) {
        if (StringUtils.isEmpty(key)) {
            return null;
        }
        RunParams runParams=DataCenter.getData("runParams", RunParams.class);
        for (KeyValue keyValue : runParams.getParams()) {
            if(key.equals(keyValue.getKey())){
                return keyValue.getValue();
            }
        }
        commonJob.log("no key------"+key+"-----");
        return null;
    }

    protected void log(String msg) {
        commonJob.log(msg);
    }

}
